package com.chenliang.sc.interceptor;



import com.chenliang.sc.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: sbd
 * @description:
 * @author: 陈英俊
 * @create: 2021-12-30 15:14
 */
public class MyInterceptor01  implements HandlerInterceptor {
    

    @Autowired
    private User user;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("MyInterceptor01的preHandle");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("打印当前拦截器类@Autowired注入的对象:"+user);
        System.out.println("MyInterceptor01的postHandle");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("MyInterceptor01的afterCompletion");
    }
}
